;Copyright 2007-2010 Niko Carpenter and Tyler Spivey
;    This file is part of Linna Home Server.
;    Linna Home is free software: you can redistribute it and/or modify
;    it under the terms of the GNU General Public License as published by
;    the Free Software Foundation, either version 3 of the License, or
;    any later version.

;    Linna Home is distributed in the hope that it will be useful,
;    but WITHOUT ANY WARRANTY; without even the implied warranty of
;    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;    GNU General Public License for more details.

;    You should have received a copy of the GNU General Public License
;    along with Linna Home.  If not, see http://www.gnu.org/licenses/.

#include-once
Func p_passwd($id,$str)
if $str = "" Then
dSend($id,$echo_on&"Passwords cannot be blank.")
lreturn($id)
return
EndIf
if $cons[$id][$C_pdata] = "" Then
dSend($id,"Please confirm your password.")
$cons[$id][$C_pdata] = _dkey($str,$str,1,1)
Else
if _dkey($str,$str,1,1) = $Cons[$id][$C_pdata] Then
if INIWrite("users.ini",$cons[$id][$c_User],"pass",_dkey($str,"hmlin"&$str&$cons[$id][$c_User]&$str,1,1)) Then
dSend($id,$echo_on&"Password updated successfully.")
Else
dSend($id,$echo_on&"Could not change your password. The user file might be read only. Please contact the owner of this server if the problem persists.")
EndIf
Else
dSend($id,$echo_on&"Passwords did not match.")
EndIf
lreturn($id)
EndIf
EndFunc
